home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14186 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  935 b 

  1. Path: gate.compart.fi!usenet
  2. From: joonas.kervinen@pcb.compart.fi (joonas kervinen)
  3. Newsgroups: comp.lang.c
  4. Subject: How to detect if a number has fractions
  5. Date: Fri, 12 Apr 1996 20:27:13 GMT
  6. Organization: Compart Internet, Helsinki, Finland
  7. Message-ID: <4klb63$h4e@gate.compart.fi>
  8. NNTP-Posting-Host: spider.compart.fi
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. Here's a small detail  that's bugging me: How do I detect in Borland C
  12. (BCC4.5 or 5.0) whether a double value has fractions. And I mean
  13. quickly, not using time consuming floating point functions (floor()
  14. ceil() etc.).
  15. I got many replies using something like:
  16. if (doublenum==(double)(int)doublenum)
  17.   puts("no fractions");
  18.  
  19. But unfortunately it does work for numbers below (about) 32000. Using
  20. long helps a little but not all. So the question remains.
  21.  
  22. Another addition: I'd also like to know how many faction (like 3 in
  23. 23.234) a double contains.
  24.  
  25. Please answer via e-mail.
  26.  
  27.